#include "stack.h"

#define UP

static unsigned int stack [STACK_WORDS];
static unsigned int *free = stack;
//static unsigned int *free = stack + STACK_WORDS - 1;

void *allocateStack (unsigned int size)
{
	void *p;
#if 0
	if (free - size + 1 < stack || size == 0)
	{
		return 0;
	}
	else
	{
		p = (void *) free;
		free -= size;
	}
#else
	if (free + size > stack + STACK_WORDS - 1 || size == 0)
	{
		return 0;
	}
	else
	{
		free += size;
		p = (void *) (free - 1);
	}
#endif
	return p;
}

